<template>
    <div>
        <h3>当前酒店房型数据统计</h3>
    <div id="main" :style="{width: '1200px', height: '600px'}"></div>
    </div>
</template>

<script>
    import echarts from 'echarts'
    require('echarts/theme/macarons') // echarts theme
    export default {
        name: "demo1",
        data(){
          return{
              labList:[]
          }
        },
        mounted() {
            this.initChart();
        },
        methods:{
            initChart() {
                this.char=echarts.init(document.getElementById("main"));
                this.char.setOption({
                    roseType: 'angle',
                    tooltip:{},
                    series:[
                        {
                            name: '房型详情',
                            type: 'pie',
                            radius: '55%',
                            data: []
                        }
                    ]
                });
      const usercode = window.sessionStorage.getItem('token')
      this.axios.get("http://localhost:8090/type/getTypeData/"+usercode).then(res=>{
        this.labList = res.data
                        // this.labList = eval('('+data+')');
                        this.char.setOption({
                            series:[
                                {
                                    name: '房型详情',
                                    type: 'pie',
                                    radius: '55%',
                                    data:this.labList
                                }
                            ]
                        })
                    });

            },
        }
    }
</script>
